package com.rayson.yututu.controller;

import com.rayson.yututu.common.BaseResponse;
import com.rayson.yututu.model.entity.Space;
import com.rayson.yututu.model.req.space.analyze.*;
import com.rayson.yututu.model.vo.*;
import com.rayson.yututu.service.SpaceAnalyzeService;
import com.rayson.yututu.service.UserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author: rayson
 * Description:
 * Date: 2025-01-18 10:51
 */
@RestController
@RequestMapping("/space/analyze")
public class SpaceAnalyzeController {

    @Resource
    private UserService userService;

    @Resource
    private SpaceAnalyzeService spaceAnalyzeService;


    /**
     * 查询空间使用情况
     */
    @PostMapping("/usage")
    public BaseResponse<SpaceUsageAnalyzeVO> getSpaceUsageAnalyze(@RequestBody SpaceUsageAnalyzeReq req,
                                                                  HttpServletRequest request) {
        return BaseResponse.success(spaceAnalyzeService.getSpaceUsageAnalyze(req, userService.getLoginUser(request)));
    }

    /**
     * 查询空间图片分类情况
     */
    @PostMapping("/category")
    public BaseResponse<List<SpaceCategoryAnalyzeVO>> getSpaceCategoryAnalyze(@RequestBody SpaceCategoryAnalyzeReq req,
                                                                              HttpServletRequest request) {
        return BaseResponse.success(spaceAnalyzeService.getSpaceCategoryAnalyze(req, userService.getLoginUser(request)));
    }

    /**
     * 查询空间图片标签情况
     */
    @PostMapping("/tag")
    public BaseResponse<List<SpaceTagAnalyzeVO>> getSpaceTagAnalyze(@RequestBody SpaceTagAnalyzeReq req,
                                                                    HttpServletRequest request) {
        return BaseResponse.success(spaceAnalyzeService.getSpaceTagAnalyze(req, userService.getLoginUser(request)));
    }

    /**
     * 查询空间图片大小情况
     */
    @PostMapping("/size")
    public BaseResponse<List<SpaceSizeAnalyzeVO>> getSpaceSizeAnalyze(@RequestBody SpaceSizeAnalyzeReq req,
                                                                      HttpServletRequest request) {
        return BaseResponse.success(spaceAnalyzeService.getSpaceSizeAnalyze(req, userService.getLoginUser(request)));
    }

    /**
     * 查询用户行为分析
     */
    @PostMapping("/user")
    public BaseResponse<List<SpaceUserAnalyzeVO>> getSpaceUserAnalyze(@RequestBody SpaceUserAnalyzeReq req,
                                                                      HttpServletRequest request) {
        return BaseResponse.success(spaceAnalyzeService.getSpaceUserAnalyze(req, userService.getLoginUser(request)));
    }

    /**
     * 查询空间使用排行
     */
    @PostMapping("/rank")
    public BaseResponse<List<Space>> getSpaceRankAnalyze(@RequestBody SpaceRankAnalyzeReq req,
                                                         HttpServletRequest request) {
        return BaseResponse.success(spaceAnalyzeService.getSpaceRankAnalyze(req, userService.getLoginUser(request)));
    }
}
